var http=require("http");
var fs=require("fs");
var urlA=require("url");
http.createServer(function(req,res){
	var url=urlA.parse(req.url).pathname;
	console.log(req.url) 
	res.setHeader("Access-Control-Allow-Origin","*");
	
	if(url=='/favicon.ico'){
		res.end();  
		return; 
	}else{
		fs.readFile("../data"+url+".json",function(err,data){
		if(err){
			res.write("404");
			console.log(err)
		}else{
			res.writeHead(200,{"Content-Type":"text/html;charset=utf-8"});
			res.write(data)
		}
		res.end();
	})
  }
	
}).listen(6666);
console.log("运行中")
